    <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header(流量卡终端查询)" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label style="width: 120px;">SN编号：</label>
                            <input type="text" name="machineNum" >
                        </li>
                        <li>
                            <label style="width: 120px;">服务商编号：</label>
                            <input type="text" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" name="agentNum"/>
                        </li>
                        <li>
                            <label style="width: 120px;">服务商名称：</label>
                            <input type="text" name="agentName"/>
                        </li>
                        <li>
                            <label style="width: 120px;">终端类型：</label>
                            <select name="posType">
                                <option value="">请选择</option>
                                <option value="4">电签Pos</option>
                                <option value="0">传统Pos</option>
                                <option value="5">GB传统</option>
                                <option value="6">GB电签</option>
                                <option value="7">GB电签二</option>

                            </select>
                        </li>
                        <li class="select-time">
                            <label style="width: 120px;">划拨日期：</label>
                            <input type="text" readonly class="startDate" value=""  id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                            <span>-</span>
                            <input type="text" readonly class="endDate" value="" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                        </li>
                        <li>
                            <label style="width: 120px;">所属顶级标号：</label>
                            <input type="text" name="topLevelAgent"/>
                        </li>
                        <li>
                            <label style="width: 120px;">返现服务商编号：</label>
                            <input type="text" name="returnAgentNo"/>
                        </li>
                        <li>
                            <label style="width: 120px;">返现代理商名称：</label>
                            <input type="text" name="returnAgentName"/>
                        </li>
                        <li>
                            <label style="width: 120px;">激活状态：</label>
                            <select name="activate">
                                <option value="">请选择</option>
                                <option value="1">已激活</option>
                                <option value="2">未激活</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="ybExport()" shiro:hasPermission="terminal:formalPos:ybExport">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" class="table text-nowrap"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "terminal/formalPos";
    var unbundlingMposFlag = [[${@permission.hasPermi('terminal:formalPos:unbundlingMpos')}]];
    var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];
    var dqType = [[${@dict.getType('dqType')}]];
    $(function() {
        var options = {
            url: prefix + "/cardFeeList",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "流量卡终端数据",
            firstLoad:false,
            columns: [
                {
                    field: 'machineNum',
                    title: 'SN编号'
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商名称'
                },
                {
                    field: 'posType',
                    title: '终端类型',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(terminalTypeDatas, value);
                    },
                    sortable: true
                },
                {
                    field: 'simFee',
                    title: '流量卡费',
                },
                {
                    field: 'returnAgentNo',
                    title: '返现代理商商编号'
                },
                {
                    field: 'returnAgentName',
                    title: '返现代理商名称'
                },
                {
                    field: 'activate',
                    title: '激活状态',
                    formatter: function (value, row, index) {
                        if (value == 1 ){
                            return '<span style="color: blue">已激活</span>';
                        } else if(value == 2 ){
                            return '<span style="color: green">未激活</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'activateDate',
                    title: '激活时间',
                },
                {
                    field: 'topLevelAgent',
                    title: '所属顶级编号',
                },
                {
                    field: 'topLevelAgentName',
                    title: '所属顶级人名称'
                },
                {
                    field: 'merno',
                    title: '商户编号'
                },
                {
                    field: 'returnDate',
                    title: '应扣费日期',
                },
                {
                    field: 'returnMoney',
                    title: '返现金额'
                },
                // {
                //     field: 'tax',
                //     title: '税点(%)',
                //     formatter: function (value, row, index) {
                //         return value+"%";
                //     }
                // },
                {
                    field: 'addDate',
                    title: '划拨日期'
                }]
        };
        $.table.init(options);
    });

    // 导出数据
    function ybExport(formId) {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        $.modal.confirm("确定导出" + table.options.modalName + "吗？", function() {
            var url = prefix + '/cardExport';
            var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
            var params = $("#" + table.options.id).bootstrapTable('getOptions');
            var dataParam = $("#" + currentId).serializeArray();
            dataParam.push({ "name": "orderByColumn", "value": params.sortName });
            dataParam.push({ "name": "isAsc", "value": params.sortOrder });
            $.modal.loading("正在导出数据，请稍后...");
            $.post(url, dataParam, function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            });
        });
    }
</script>
</body>
</html>
